# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php7-pecl-swoole
_pkgreal=swoole
pkgver=4.5.2
pkgrel=2
pkgdesc="Event-driven asynchronous and concurrent networking engine with high performance for PHP."
url="https://pecl.php.net/package/swoole"
arch="all"
license="Apache-2.0"
depends="php7-openssl php7-sockets"
makedepends="php7-dev autoconf re2c openssl-dev nghttp2-dev libucontext-dev"
source="https://pecl.php.net/get/$_pkgreal-$pkgver.tgz"
builddir="$srcdir"/$_pkgreal-$pkgver
subpackages="$pkgname-dev"

build() {
	case "$CARCH" in
		ppc64le|s390x|x86) export LDFLAGS="$LDFLAGS -lucontext" ;;
	esac
	phpize7
	./configure --prefix=/usr \
		--with-php-config=php-config7 \
		--enable-openssl \
		--enable-sockets \
		--enable-http2
	make
}

check() {
	# needs extra services to test all suite
	php7 -d extension="$builddir"/modules/swoole.so --ri swoole
}

package() {
	make INSTALL_ROOT="$pkgdir"/ install
	install -d "$pkgdir"/etc/php7/conf.d
	echo "extension=$_pkgreal.so" > "$pkgdir"/etc/php7/conf.d/50_$_pkgreal.ini
}

sha512sums="ee42521e0830dedc463c2a7af00e963cb22793ad4c06f38082d24764581c3ce96dc46b0ac194196d404ab9ff1480abc7776569cbe06481396217469659f334bc  swoole-4.5.2.tgz"
